package com.yodawnla.littleWar.card;

import org.anddev.andengine.entity.sprite.TiledSprite;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

import com.yodawnla.lib.util.YoInt;
import com.yodawnla.lib.util.widget.YoText;
import com.yodawnla.littleWar.system.Fonts;
import com.yodawnla.littleWar.system.Values;

public class HandCard extends TiledSprite
{
	boolean mIsOnHand = false;
	int mType = Values.HandCardType.Red;
	//TiledSprite mTypeSprite;
	YoText mDamageText;
	YoInt mAmount = new YoInt(0);
	YoInt mDamage = new YoInt(0);
	
	public HandCard(float pX, float pY, TiledTextureRegion pTiledTextureRegion)
	{
		super(pX, pY, pTiledTextureRegion);
		
		mDamageText = new YoText(30, 80, Fonts.Rock30, "0", 3);
		attachChild(mDamageText);
	}
	
	public void showDamageText(boolean isVisible)
	{
		mDamageText.setVisible(isVisible);
	}
	
	public void setIsOnHand(boolean isOnHand)
	{
		mIsOnHand = isOnHand;
	}
	
	public boolean getIsOnHand()
	{
		return mIsOnHand;
	}
	
	public void setType(int type)
	{
		mType = type;
		//TextureRegion tex = null;
		switch(type)
		{
		case Values.HandCardType.Red:
			setCurrentTileIndex(0);
			break;
		case Values.HandCardType.Green:
			setCurrentTileIndex(1);
			//tex = YoActivity.getBaseActivity().getTexture(Tex.type1);
			break;
		case Values.HandCardType.Blue:
			setCurrentTileIndex(2);
			//tex = YoActivity.getBaseActivity().getTexture(Tex.type2);
			break;
		}
		//Sprite typeSprite = new Sprite(55, 88, tex);
		//attachChild(typeSprite);*/
	}
	
	public void setDamage(int damage)
	{
		mDamage.set(-damage);
		mDamageText.setText("" + damage);
	}
	
	public int getAmount()
	{
		return mAmount.get();
	}
	
	public int getType()
	{
		return mType;
	}
	
	public int getDamage()
	{
		return mDamage.get();
	}
}